package cz.su.pod.reservation;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

public class SpringBean implements ApplicationContextAware {
	private static ApplicationContext CONTEXT;
	
	@Override
	public void setApplicationContext(ApplicationContext arg0)
			throws BeansException {
		CONTEXT = arg0;
	}
	
	public static Object getBean(String beanId) {
		return CONTEXT.getBean(beanId);
	}
	
	public static <T> T getBean(Class<T> clazz) {
		return CONTEXT.getBean(clazz);
	}
	
	public static <T> T getBean(String beanId, Class<T> clazz) {
		return CONTEXT.getBean(beanId, clazz);
	}

}
